<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // 声明对象
    // let obj = new obj();
    let obj = {
      uname: "caiwan",
      age: 18,
      gender: "male"
    }
    console.log(obj);
    console.log(typeof (obj));

    console.log(obj.uname);

    // test

    let goods = {
      gname: "小米小米10 青春版",
      num: 100012816024,
      weight: "0.55kg",
      address: "中国大陆",
    }
    //增加  增加和修改的方法一样
    goods.price = "3999$";
    console.log(goods);
    // 删除
    delete goods.price;
    console.log(goods);

    goods.sing = function () {
      console.log("hi");
    }
    console.log(goods);
    console.log(goods.gname);
    console.log(goods.sing());

    goods.gname = "xiaomi 10 plus";
    goods["goods-name"] = "xiaomi 10 plus";
    goods.color = "red";
    console.log(goods.gname);
    console.log(goods.num);
    console.log(goods.weight);
    console.log(goods.color);
    console.log(goods.sing());
    console.log(goods["goods-name"]);
    console.log(goods);
    console.log(goods["color"]);


    // 查找的两种方法
    // （1）对象名.属性名  goods.gname
    //  (2) 对象名["属性名"]（此处一定要加引号） goods["goods-name"]

    // 遍历对象
  </script>
</body>

</html>